A good answer might be:

The complete program is given below.


Complete Sentinel Program

import java.io.*;
class AddUpAllSentinel
{
  public static void main ( String[] args ) throws IOException
  {
    int value;     // the value of the current integer
    int sum = 0;   // initialize sum

    String line;
    BufferedReader stdin = new BufferedReader( 
        new InputStreamReader( System.in ) );

    // get first integer
    System.out.println("Enter first integer:");
    line   = stdin.readLine();
    value  = Integer.parseInt( line.trim() );

    int count = 0; // initialize count

    while ( value >= 0 )
    {
      sum    = sum + value; // add to the sum
      count  = count + 1;   // increment count

      System.out.println("Enter a number:");
      line   = stdin.readLine();
      value  = Integer.parseInt( line.trim() );
    }

    System.out.println( "Grand Total: " + sum );
  }
}

QUESTION 15:

Could the sentinel method be used for a file that contains two or more groups of data?